trigger update_snaglist_status on SnagList__c (before insert,after insert,before update,after update) 

    {
    
        if(trigger.isbefore && trigger.isinsert)
        
            {
                for(SnagList__c snaglist: trigger.new)
                {
                
                    snaglist.Status__c='New';
                    snaglist.Created_Date__c=System.TODAY();
                }
            
            }
            
         if(trigger.isbefore && trigger.isupdate)
         
         {
              for(SnagList__c snaglist :trigger.new)
                     
                  {                        
                         if(snaglist.Status__c=='Closed')
                         
                             {
                                snaglist.Closed_Date__c=system.TODAY();
                             }
                         
                   }
                 
         
         }
         
             
         
     
    
    }